/*
 * Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import com.xuexiang.templateproject.bean.Box;
import com.xuexiang.templateproject.bean.ImageBoxEntity;
import com.xuexiang.templateproject.core.BaseActivity;

import java.util.LinkedHashMap;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.xuexiang.templateproject.R;
import com.xuexiang.templateproject.databinding.ActivityBoxEditBinding;
import com.xuexiang.templateproject.widget.RectView;
import com.xuexiang.xaop.annotation.SingleClick;

public final class BoxEditActivity extends BaseActivity<ActivityBoxEditBinding> implements View.OnClickListener {
    @Nullable

    /* renamed from: b  reason: collision with root package name */
    public RectView f3897b;
    @NotNull

    /* renamed from: c  reason: collision with root package name */
    public Map<Integer, View> f3898c = new LinkedHashMap();
    @Override
    protected ActivityBoxEditBinding viewBindingInflate(LayoutInflater inflater) {
        return ActivityBoxEditBinding.inflate(inflater);
    }
    public void _$_clearFindViewByIdCache() {
        this.f3898c.clear();
    }

    @Nullable
    public View _$_findCachedViewById(int i2) {
        Map<Integer, View> map = this.f3898c;
        View view = map.get(Integer.valueOf(i2));
        if (view != null) {
            return view;
        }
        View findViewById = findViewById(i2);
        if (findViewById == null) {
            return null;
        }
        map.put(Integer.valueOf(i2), findViewById);
        return findViewById;
    }

    @Override
    protected void onCreate(@androidx.annotation.Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

//        XRouter.getInstance().inject(this);

        initData();
        initEvent();
    }
    public void initData() {

        Bundle extras = getIntent().getExtras();
        Object obj = null;
        Object obj2 = extras != null ? extras.get("ImageBoxEntity") : null;

        ImageBoxEntity imageBoxEntity = (ImageBoxEntity) obj2;
        Bundle extras2 = getIntent().getExtras();
        if (extras2 != null) {
            obj = extras2.get("box");
        }
        this.f3897b = new RectView(this, imageBoxEntity, (Box) obj);
        binding.llContent.addView(this.f3897b);
//        ((LinearLayout) _$_findCachedViewById(R.id.llContent)).addView(this.f3897b);
    }

    public void initEvent() {
        binding.tvDone.setOnClickListener(this);
        binding.tvDelete.setOnClickListener(this);
    }
    @SingleClick
    @Override // android.view.View.OnClickListener
    public void onClick(@Nullable View view) {
        Box box = null;
        Integer valueOf = view != null ? Integer.valueOf(view.getId()) : null;
        if (valueOf != null && valueOf.intValue() == R.id.tvDelete) {
            setResult(2);
            finish();
        } else if (valueOf != null && valueOf.intValue() == R.id.tvDone) {
            RectView rectView = this.f3897b;
            if (rectView != null) {
                box = rectView.getBox();
            }
            Intent intent = new Intent();
            intent.putExtra("box", box);
            setResult(1, intent);
            finish();
        }
    }
}